import { IsDate, IsEnum, IsInt, IsNotEmpty, IsOptional, IsString, IsArray } from 'class-validator'
import { Type } from 'class-transformer'
import { ApiProperty } from '@nestjs/swagger'
import { CClassStatus } from '../constant'

export class CreateClassDto {
  @ApiProperty({ description: '班级ID' })
  @IsString()
  @IsNotEmpty()
  classId: string

  @ApiProperty({ description: '班级名称' })
  @IsString()
  @IsNotEmpty()
  className: string

  @ApiProperty({ description: '班级学级，0 幼儿园，1-6 小学，7-8 初中', default: 0 })
  @IsInt()
  @IsNotEmpty()
  classGrade: number

  @ApiProperty({ description: '带班老师ID' })
  @IsInt()
  @IsOptional()
  classTeacher: number

  @ApiProperty({ description: '开始时间', required: false })
  @IsOptional()
  @Type(() => Date)
  @IsDate()
  startAt?: Date

  @ApiProperty({ description: '毕业时间', required: false })
  @IsOptional()
  @Type(() => Date)
  @IsDate()
  expireAt?: Date

  @ApiProperty({ description: '状态', enum: CClassStatus, default: CClassStatus.Active })
  @IsEnum(CClassStatus)
  @IsOptional()
  status?: CClassStatus = CClassStatus.Active

  @ApiProperty({ description: '学习计划', required: false })
  @IsOptional()
  @IsString()
  studyPlan?: string
  
  @ApiProperty({ description: '学生ID列表(旧字段名)', type: [Number], required: false })
  @IsOptional()
  @IsArray()
  @IsInt({ each: true })
  @Type(() => Number)
  studentIds?: number[]

  @ApiProperty({ description: '选中的学生ID列表', type: [Number], required: false })
  @IsOptional()
  @IsArray()
  @IsInt({ each: true })
  @Type(() => Number)
  selectedStudents?: number[]
}